<template>
  <a-drawer
    width="384"
    :title="formTitle"
    :label-col="4"
    :wrapper-col="14"
    :visible="open"
    :body-style="{height:'calc(100vh - 100px)',overflow:'auto'}"
    @close="cancel">
    <a-form-model ref="form" :model="form" :rules="rules" layout="vertical">
      <a-spin :spinning="spinning" :delay="delayTime" tip="Loading...">
        <a-row :gutter="32">
          <a-col :span="24">
            <a-form-model-item label="商品名称" prop="goodsName">
              <a-input v-model="form.goodsName" placeholder="请输入商品名称"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="商品描述" prop="goodsDes">
              <a-textarea v-model="form.goodsDes" placeholder="请输入商品描述" :rows="4"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="商品价格(元)" prop="price">
              <a-input-number v-model="form.price" :min="0" style="width: 100%"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="商品重量(kg)" prop="weight">
              <a-input-number v-model="form.weight" :min="0" style="width: 100%"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24" >
            <a-form-model-item label="商品类别" prop="category">
              <a-select
                placeholder="请选择商品类别"
                v-model="form.category"
                :getPopupContainer="
                  triggerNode => {
                    return triggerNode.parentNode || document.body
                  }
                "
                style="width: 100%"
                allow-clear>
                <a-select-option v-for="(d, index) in categoryOptions" :key="index" :value="d.dictValue">{{ d.dictLabel }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="供应商" prop="supplierId">
              <a-input v-model="form.supplierId" placeholder="请输入供应商"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="有效期" prop="validity">
              <a-date-picker
                v-model="form.validity"
                valueFormat="YYYY-MM-DD"
                :show-today="true"
                placeholder="选择日期"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="24" >
            <a-form-model-item label="状态" prop="state">
              <a-select
                placeholder="请选择状态"
                v-model="form.state"
                :getPopupContainer="
                  triggerNode => {
                    return triggerNode.parentNode || document.body
                  }
                "
                style="width: 100%"
                allow-clear>
                <a-select-option v-for="(d, index) in stateOptions" :key="index" :value="d.dictValue">{{ d.dictLabel }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="备注" prop="remark">
              <a-input v-model="form.remark" placeholder="请输入备注"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-spin>
      <div class="bottom-control">
        <a-space>
          <a-button :disabled="disabled" @click="cancel">
            取消
          </a-button>
          <a-button type="primary" :disabled="disabled" @click="submitForm(true)">
            保存
          </a-button>
        </a-space>
      </div>
    </a-form-model>
  </a-drawer>
</template>
<script>
import BaseGoodsinfoEditForm from './BaseGoodsinfoForm'
export default {
  ...BaseGoodsinfoEditForm
}
</script>
